home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / a_utils / expanded.lha / test_suite / testmulti.C < prev    next >
C/C++ Source or Header  |  1992-03-19  |  37KB  |  1,162 lines

  1. //
  2. // Linear-Affine-Projective Geometry Package
  3. //
  4. // testmulti.C
  5. //
  6. // $Header$
  7. //
  8. // William J.R. Longabaugh 
  9. // University of Washington
  10. //
  11. // Test programs for the linear-affine-projective geometry
  12. // package described in William J.R. Longabaugh, "An Expanded
  13. // System for Coordinate-Free Geometric Programming", Master's 
  14. // thesis, University of Washington, 1992.
  15. //
  16. // Copyright (c) 1992, William J.R. Longabaugh
  17. //   Copying, use and development for non-commercial purposes permitted.
  18. //   All rights for commercial use reserved.
  19. //   This software is unsupported and without warranty; it is
  20. //   provided "as is".
  21. //
  22. // ***********************************************************************
  23.  
  24. #include "Lap.h"
  25. #include <math.h>
  26.  
  27. extern void test1(void);
  28. extern void test2(void);
  29. extern void test3(void);
  30. extern void test4(void);
  31. extern void test5(void);
  32. extern void test6(void);
  33. extern void test7(void);
  34. extern void test8(void);
  35. extern void test9(void);
  36. extern void test10(void);
  37. extern void test11(void);
  38. extern void truth(Boolean res, Boolean expect);
  39. extern void beauty(void);
  40.  
  41. static int count = 0;
  42.  
  43. // ***********************************************************************
  44.  
  45. void truth(Boolean res, Boolean expect)
  46. {
  47.   if (res != expect) { 
  48.     cout << "Failure at: " << count << "\n";
  49.   }
  50.   count++;    
  51. }
  52.  
  53. // ***********************************************************************
  54.  
  55. void beauty(void)
  56. {
  57.   cout << "Now at: " << count << "\n";
  58. }
  59.  
  60. // ***********************************************************************
  61.  
  62. int main(void)
  63. {
  64.   test1(); 
  65.   test2();
  66.   test3();
  67.   test4();
  68.   test5();
  69.   test6();
  70.   test7();
  71.   test8();
  72.   test9();
  73.   test10();
  74.   test11();
  75.   return (0);
  76. }
  77.  
  78. // ***********************************************************************
  79. // Quadratic surface:
  80.  
  81. void test1(void)
  82. {
  83.   cout << "ENTERING TEST1\n";
  84.   beauty();
  85.   ASpace param("paramspace", 2, TRUE);
  86.   Simplex smp1 = param.StdSimplex();
  87.  
  88.   APoint s1(smp1, ScalarList(0.4, 0.3, 0.3));
  89.   APoint s2(smp1, ScalarList(1.5, 2.0, -2.5));
  90.   APoint s3(smp1, ScalarList(0.9, -0.3, 0.4));
  91.  
  92.   Simplex mysimp("my simplex", param, GeObList(s1, s2, s3));
  93.  
  94.   ASpace rng("rngspace", 3, TRUE);
  95.   Frame fr2 = rng.StdBasis();
  96.  
  97.   ASpace domsp("testdom", SpaceList(param, 2), FALSE);
  98.  
  99.   IntList hold(1);
  100.   hold[0] = 2;
  101.  
  102.   APoint aa(fr2, ScalarList(0.0, 0.0, 0.0, 1.0));
  103.   APoint ab(fr2, ScalarList(1.0, 0.0, 0.3, 1.0));
  104.   APoint bb(fr2, ScalarList(2.0, 0.0, 0.0, 1.0));
  105.   APoint ac(fr2, ScalarList(0.5, 1.0, 0.3, 1.0));
  106.   APoint bc(fr2, ScalarList(1.5, 1.0, 0.3, 1.0));
  107.   APoint cc(fr2, ScalarList(1.0, 2.0, 0.0, 1.0));
  108.   
  109.   GeObList net = GeObList(aa, ab, bb) + GeObList(ac, bc, cc);
  110.   MAM tstmp(domsp, hold, BasisList(mysimp), rng, net);
  111.  
  112.   APoint pt1(mysimp, ScalarList(1.0, 0.0, 0.0));
  113.   APoint pt2(mysimp, ScalarList(0.0, 1.0, 0.0));
  114.   APoint pt3(mysimp, ScalarList(0.0, 0.0, 1.0));
  115.  
  116.   APoint argpt1(domsp, pt1, pt1);
  117.   APoint argpt2(domsp, pt1, pt2);
  118.   APoint argpt3(domsp, pt2, pt2);
  119.   APoint argpt4(domsp, pt1, pt3);
  120.   APoint argpt5(domsp, pt2, pt3);
  121.   APoint argpt6(domsp, pt3, pt3);
  122.  
  123.   APoint xout;
  124.   xout = tstmp(argpt1);
  125.   truth((xout - aa).IsZeroVector(), TRUE);
  126.   xout = tstmp(argpt2);
  127.   truth((xout - ab).IsZeroVector(), TRUE);
  128.   xout = tstmp(argpt3);
  129.   truth((xout - bb).IsZeroVector(), TRUE);
  130.   xout = tstmp(argpt4);
  131.   truth((xout - ac).IsZeroVector(), TRUE);
  132.   xout = tstmp(argpt5);
  133.   truth((xout - bc).IsZeroVector(), TRUE);
  134.   xout = tstmp(argpt6);
  135.   truth((xout - cc).IsZeroVector(), TRUE);
  136.  
  137. // Test partial evaluation
  138.  
  139.   GeObList part = GeObList(pt1, NullGeOb);
  140.  
  141.   MAM mout = tstmp(part);
  142.   truth(mout.FullyEvaluated(), FALSE);
  143.   truth(mout.DomainSpace() == param, TRUE);
  144.   truth(mout.RangeSpace() == rng, TRUE);
  145.  
  146.   mout = tstmp(param, part);
  147.   truth(mout.FullyEvaluated(), FALSE);
  148.   truth(mout.DomainSpace() == param, TRUE);
  149.   truth(mout.RangeSpace() == rng, TRUE);
  150.  
  151.   xout = mout(pt2);
  152.   truth((xout - ab).IsZeroVector(), TRUE);
  153.   AVector tout = mout(GeObList(pt1 - pt2));
  154.   truth((tout - (aa - ab)).IsZeroVector(), TRUE);
  155.  
  156. // Test range space changes and acceptance of tangent vectors
  157.   
  158.   VSpace tan = domsp.GetSpace(TANGENT);
  159.   VSpace rtan = rng.GetSpace(TANGENT);
  160.   AVector argvec1(tan, pt1 - pt2, pt1 - pt2);
  161.   GeOb gout1 = tstmp(argvec1);
  162.   truth(gout1.Holds() == AFF_VECTOR, TRUE);
  163.  
  164.   mout = tstmp(GeObList((pt1 - pt2), NullGeOb));
  165.   truth(mout.FullyEvaluated(), FALSE);
  166.   truth(mout.DomainSpace() == param, TRUE);
  167.   truth(mout.RangeSpace() == rtan, TRUE);
  168.  
  169.   GeOb gout2 = mout(GeObList(pt1 - pt2));
  170.   truth((gout2 - gout1).IsZeroVector(), TRUE);
  171. }
  172.  
  173. // ***********************************************************************
  174. // Test a cubic by quartic tensor product surface
  175. //
  176.  
  177. void test2(void)
  178. {
  179.   cout << "ENTERING TEST2\n";
  180.   beauty();
  181.  
  182.   ASpace paramab("paramab", 1, TRUE);
  183.   Simplex smp1 = paramab.StdSimplex();
  184.  
  185.   ASpace paramcd("paramcd", 1, TRUE);
  186.   Simplex smp2 = paramcd.StdSimplex();
  187.  
  188.   ASpace rng("rngspace", 3, TRUE);
  189.   Frame fr2 = rng.StdBasis();
  190.  
  191.   ASpace domsp("domsp", 
  192.     SpaceList(paramab, paramab, paramab) + SpaceList(paramcd, paramcd), FALSE);
  193.  
  194.   APoint sab1(smp1, ScalarList(0.3, 0.7));
  195.   APoint sab2(smp1, ScalarList(1.3, -0.3));
  196.  
  197.   Simplex mysmpab("my simplexab", paramab, GeObList(sab1, sab2));
  198.  
  199.   APoint scd1(smp2, ScalarList(0.2, 0.8));
  200.   APoint scd2(smp2, ScalarList(2.4, -1.4));
  201.  
  202.   Simplex mysmpcd("my simplexcd", paramcd, GeObList(scd1, scd2));
  203.  
  204.   IntList hold(2);
  205.   hold[0] = 3;
  206.   hold[1] = 2;
  207.  
  208.   APoint aaa_cc(fr2, ScalarList(0.0, 0.0, 0.0, 1.0));
  209.   APoint aab_cc(fr2, ScalarList(1.0, 0.0, 0.3, 1.0));
  210.   APoint abb_cc(fr2, ScalarList(2.0, 0.0, 0.2, 1.0));
  211.   APoint bbb_cc(fr2, ScalarList(3.0, 0.0, 0.0, 1.0));
  212.  
  213.   APoint aaa_cd(fr2, ScalarList(0.0, 1.0, 0.0, 1.0));
  214.   APoint aab_cd(fr2, ScalarList(1.0, 1.0, 0.8, 1.0));
  215.   APoint abb_cd(fr2, ScalarList(2.0, 1.0, 0.7, 1.0));
  216.   APoint bbb_cd(fr2, ScalarList(3.0, 1.0, 0.0, 1.0));
  217.  
  218.   APoint aaa_dd(fr2, ScalarList(0.0, 2.0, 0.0, 1.0));
  219.   APoint aab_dd(fr2, ScalarList(1.0, 2.0, 0.6, 1.0));
  220.   APoint abb_dd(fr2, ScalarList(2.0, 2.0, 0.5, 1.0));
  221.   APoint bbb_dd(fr2, ScalarList(3.0, 2.0, 0.0, 1.0));
  222.   
  223.   GeObList net = GeObList(aaa_cc, aaa_cd, aaa_dd) +
  224.        GeObList(aab_cc, aab_cd, aab_dd) +
  225.        GeObList(abb_cc, abb_cd, abb_dd) +
  226.        GeObList(bbb_cc, bbb_cd, bbb_dd);
  227.  
  228.   MAM tstmp;
  229.   tstmp = MAM(domsp, hold, BasisList(mysmpab, mysmpcd), rng, net);
  230.  
  231.   APoint a(mysmpab, ScalarList(1.0, 0.0));
  232.   APoint b(mysmpab, ScalarList(0.0, 1.0));
  233.   APoint c(mysmpcd, ScalarList(1.0, 0.0));
  234.   APoint d(mysmpcd, ScalarList(0.0, 1.0));
  235.  
  236.   APoint pt1(domsp, GeObList(a, a, a) + GeObList(c, c));
  237.   APoint pt2(domsp, GeObList(a, a, b) + GeObList(c, c));
  238.   APoint pt3(domsp, GeObList(a, b, b) + GeObList(c, c));
  239.   APoint pt4(domsp, GeObList(b, b, b) + GeObList(c, c));
  240.   APoint pt5(domsp, GeObList(a, a, a) + GeObList(c, d));
  241.   APoint pt6(domsp, GeObList(a, a, b) + GeObList(c, d));
  242.   APoint pt7(domsp, GeObList(a, b, b) + GeObList(c, d));
  243.   APoint pt8(domsp, GeObList(b, b, b) + GeObList(c, d));
  244.   APoint pt9(domsp, GeObList(a, a, a) + GeObList(d, d));
  245.   APoint pt10(domsp, GeObList(a, a, b) + GeObList(d, d));
  246.   APoint pt11(domsp, GeObList(a, b, b) + GeObList(d, d));
  247.   APoint pt12(domsp, GeObList(b, b, b) + GeObList(d, d));
  248.  
  249.   APoint xout;
  250.   xout = tstmp(pt1);
  251.   truth((xout - aaa_cc).IsZeroVector(), TRUE);
  252.   xout = tstmp(pt2);
  253.   truth((xout - aab_cc).IsZeroVector(), TRUE);
  254.   xout = tstmp(pt3);
  255.   truth((xout - abb_cc).IsZeroVector(), TRUE);
  256.   xout = tstmp(pt4);
  257.   truth((xout - bbb_cc).IsZeroVector(), TRUE);
  258.   xout = tstmp(pt5);
  259.   truth((xout - aaa_cd).IsZeroVector(), TRUE);
  260.   xout = tstmp(pt6);
  261.   truth((xout - aab_cd).IsZeroVector(), TRUE);
  262.   xout = tstmp(pt7);
  263.   truth((xout - abb_cd).IsZeroVector(), TRUE);
  264.   xout = tstmp(pt8);
  265.   truth((xout - bbb_cd).IsZeroVector(), TRUE);
  266.   xout = tstmp(pt9);
  267.   truth((xout - aaa_dd).IsZeroVector(), TRUE);
  268.   xout = tstmp(pt10);
  269.   truth((xout - aab_dd).IsZeroVector(), TRUE);
  270.   xout = tstmp(pt11);
  271.   truth((xout - abb_dd).IsZeroVector(), TRUE);
  272.   xout = tstmp(pt12);
  273.   truth((xout - bbb_dd).IsZeroVector(), TRUE);
  274.  
  275. // Test partial evaluation
  276.  
  277.   GeObList part = GeObList(a, NullGeOb, a) + GeObList(d, NullGeOb);
  278.   ASpace inter("inter", SpaceList(paramab, paramcd), FALSE);
  279.  
  280.   MAM mout = tstmp(inter, part);
  281.   truth(mout.FullyEvaluated(), FALSE);
  282.   truth(mout.DomainSpace() == inter, TRUE);
  283.   truth(mout.RangeSpace() == rng, TRUE);
  284.  
  285.   part = GeObList(a, d);
  286.   xout = mout(part);
  287.   truth((xout - aaa_dd).IsZeroVector(), TRUE);
  288.  
  289.   part = GeObList(a, d - c);
  290.   AVector tout = mout(part);
  291.   truth((tout - (aaa_dd - aaa_cd)).IsZeroVector(), TRUE);
  292.  
  293. // Test range space changes and acceptance of tangent vectors
  294.   
  295.   VSpace tan = domsp.GetSpace(TANGENT);
  296.   VSpace rtan = rng.GetSpace(TANGENT);
  297.   AVector argvec1(tan, GeObList(a - b, a - b, a - b) +
  298.                GeObList(d - c, d - c));
  299.   GeOb tout1 = tstmp(argvec1);
  300.   truth(tout1.Holds() == AFF_VECTOR, TRUE);
  301.  
  302. }
  303.  
  304. // ***********************************************************************
  305. //  Test from 1 x 1 x 1 -> 3
  306.  
  307. void test3(void)
  308. {
  309.   cout << "ENTERING TEST3\n";
  310.   beauty();
  311.   ASpace paramab("paramab", 1, TRUE);
  312.   Simplex smp1 = paramab.StdSimplex();
  313.  
  314.   ASpace paramcd("paramcd", 1, TRUE);
  315.   Simplex smp2 = paramcd.StdSimplex();
  316.  
  317.   ASpace paramef("paramef", 1, TRUE);
  318.   Simplex smp3 = paramef.StdSimplex();
  319.  
  320.   ASpace rng("rngspace", 3, TRUE);
  321.   Frame fr2 = rng.StdBasis();
  322.  
  323.   ASpace domsp("domsp", SpaceList(paramab, paramab, paramcd, paramcd) +
  324.                         SpaceList(paramef, paramef), FALSE);
  325.  
  326.   APoint sab1(smp1, ScalarList(0.3, 0.7));
  327.   APoint sab2(smp1, ScalarList(1.3, -0.3));
  328.  
  329.   Simplex mysmpab("my simplexab", paramab, GeObList(sab1, sab2));
  330.  
  331.   APoint scd1(smp2, ScalarList(0.2, 0.8));
  332.   APoint scd2(smp2, ScalarList(2.4, -1.4));
  333.  
  334.   Simplex mysmpcd("my simplexcd", paramcd, GeObList(scd1, scd2));
  335.  
  336.   APoint sef1(smp3, ScalarList(0.1, 0.9));
  337.   APoint sef2(smp3, ScalarList(1.2, -0.2));
  338.  
  339.   Simplex mysmpef("my simplexef", paramef, GeObList(sef1, sef2));
  340.  
  341.   IntList hold(2, 2, 2);
  342.  
  343.   APoint aa_cc_ee(fr2, ScalarList(0.0, 0.0, 0.0, 1.0));
  344.   APoint ab_cc_ee(fr2, ScalarList(1.0, 0.0, 0.3, 1.0));
  345.   APoint bb_cc_ee(fr2, ScalarList(2.0, 0.0, 0.0, 1.0));
  346.   APoint aa_cd_ee(fr2, ScalarList(0.0, 1.0, 0.3, 1.0));
  347.   APoint ab_cd_ee(fr2, ScalarList(1.0, 1.0, 0.6, 1.0));
  348.   APoint bb_cd_ee(fr2, ScalarList(2.0, 1.0, 0.3, 1.0));
  349.   APoint aa_dd_ee(fr2, ScalarList(0.0, 2.0, 0.0, 1.0));
  350.   APoint ab_dd_ee(fr2, ScalarList(1.0, 2.0, 0.3, 1.0));
  351.   APoint bb_dd_ee(fr2, ScalarList(2.0, 2.0, 0.0, 1.0));
  352.  
  353.   APoint aa_cc_ef(fr2, ScalarList(0.0, 0.0, 1.0, 1.0));
  354.   APoint ab_cc_ef(fr2, ScalarList(1.0, 0.0, 1.3, 1.0));
  355.   APoint bb_cc_ef(fr2, ScalarList(2.0, 0.0, 1.0, 1.0));
  356.   APoint aa_cd_ef(fr2, ScalarList(0.0, 1.0, 1.3, 1.0));
  357.   APoint ab_cd_ef(fr2, ScalarList(1.0, 1.0, 1.6, 1.0));
  358.   APoint bb_cd_ef(fr2, ScalarList(2.0, 1.0, 1.3, 1.0));
  359.   APoint aa_dd_ef(fr2, ScalarList(0.0, 2.0, 1.0, 1.0));
  360.   APoint ab_dd_ef(fr2, ScalarList(1.0, 2.0, 1.3, 1.0));
  361.   APoint bb_dd_ef(fr2, ScalarList(2.0, 2.0, 1.0, 1.0));
  362.  
  363.   APoint aa_cc_ff(fr2, ScalarList(0.0, 0.0, 2.0, 1.0));
  364.   APoint ab_cc_ff(fr2, ScalarList(1.0, 0.0, 2.3, 1.0));
  365.   APoint bb_cc_ff(fr2, ScalarList(2.0, 0.0, 2.0, 1.0));
  366.   APoint aa_cd_ff(fr2, ScalarList(0.0, 1.0, 2.3, 1.0));
  367.   APoint ab_cd_ff(fr2, ScalarList(1.0, 1.0, 2.6, 1.0));
  368.   APoint bb_cd_ff(fr2, ScalarList(2.0, 1.0, 2.3, 1.0));
  369.   APoint aa_dd_ff(fr2, ScalarList(0.0, 2.0, 2.0, 1.0));
  370.   APoint ab_dd_ff(fr2, ScalarList(1.0, 2.0, 2.3, 1.0));
  371.   APoint bb_dd_ff(fr2, ScalarList(2.0, 2.0, 2.0, 1.0));
  372.   
  373.   GeObList net = GeObList(aa_cc_ee, aa_cc_ef, aa_cc_ff) +
  374.          GeObList(aa_cd_ee, aa_cd_ef, aa_cd_ff) +
  375.          GeObList(aa_dd_ee, aa_dd_ef, aa_dd_ff) +
  376.          GeObList(ab_cc_ee, ab_cc_ef, ab_cc_ff) +
  377.          GeObList(ab_cd_ee, ab_cd_ef, ab_cd_ff) +
  378.          GeObList(ab_dd_ee, ab_dd_ef, ab_dd_ff) +
  379.          GeObList(bb_cc_ee, bb_cc_ef, bb_cc_ff) +
  380.          GeObList(bb_cd_ee, bb_cd_ef, bb_cd_ff) +
  381.          GeObList(bb_dd_ee, bb_dd_ef, bb_dd_ff);
  382.  
  383.   MAM tstmp;
  384.   tstmp = MAM(domsp, hold, BasisList(mysmpab, mysmpcd, mysmpef), rng, net);
  385.  
  386.   APoint a(mysmpab, ScalarList(1.0, 0.0));
  387.   APoint b(mysmpab, ScalarList(0.0, 1.0));
  388.   APoint c(mysmpcd, ScalarList(1.0, 0.0));
  389.   APoint d(mysmpcd, ScalarList(0.0, 1.0));
  390.   APoint e(mysmpef, ScalarList(1.0, 0.0));
  391.   APoint f(mysmpef, ScalarList(0.0, 1.0));
  392.  
  393.   APoint pt1(domsp, GeObList(a, a) + GeObList(c, c) + GeObList(e, e));
  394.   APoint pt2(domsp, GeObList(a, b) + GeObList(c, c) + GeObList(e, e));
  395.   APoint pt3(domsp, GeObList(b, b) + GeObList(c, c) + GeObList(e, e));
  396.   APoint pt4(domsp, GeObList(a, a) + GeObList(c, d) + GeObList(e, e));
  397.   APoint pt5(domsp, GeObList(a, b) + GeObList(c, d) + GeObList(e, e));
  398.   APoint pt6(domsp, GeObList(b, b) + GeObList(c, d) + GeObList(e, e));
  399.   APoint pt7(domsp, GeObList(a, a) + GeObList(d, d) + GeObList(e, e));
  400.   APoint pt8(domsp, GeObList(a, b) + GeObList(d, d) + GeObList(e, e));
  401.   APoint pt9(domsp, GeObList(b, b) + GeObList(d, d) + GeObList(e, e));
  402.   APoint pt10(domsp, GeObList(a, a) + GeObList(c, c) + GeObList(e, f));
  403.   APoint pt11(domsp, GeObList(a, b) + GeObList(c, c) + GeObList(e, f));
  404.   APoint pt12(domsp, GeObList(b, b) + GeObList(c, c) + GeObList(e, f));
  405.   APoint pt13(domsp, GeObList(a, a) + GeObList(c, d) + GeObList(e, f));
  406.   APoint pt14(domsp, GeObList(a, b) + GeObList(c, d) + GeObList(e, f));
  407.   APoint pt15(domsp, GeObList(b, b) + GeObList(c, d) + GeObList(e, f));
  408.   APoint pt16(domsp, GeObList(a, a) + GeObList(d, d) + GeObList(e, f));
  409.   APoint pt17(domsp, GeObList(a, b) + GeObList(d, d) + GeObList(e, f));
  410.   APoint pt18(domsp, GeObList(b, b) + GeObList(d, d) + GeObList(e, f));
  411.   APoint pt19(domsp, GeObList(a, a) + GeObList(c, c) + GeObList(f, f));
  412.   APoint pt20(domsp, GeObList(a, b) + GeObList(c, c) + GeObList(f, f));
  413.   APoint pt21(domsp, GeObList(b, b) + GeObList(c, c) + GeObList(f, f));
  414.   APoint pt22(domsp, GeObList(a, a) + GeObList(c, d) + GeObList(f, f));
  415.   APoint pt23(domsp, GeObList(a, b) + GeObList(c, d) + GeObList(f, f));
  416.   APoint pt24(domsp, GeObList(b, b) + GeObList(c, d) + GeObList(f, f));
  417.   APoint pt25(domsp, GeObList(a, a) + GeObList(d, d) + GeObList(f, f));
  418.   APoint pt26(domsp, GeObList(a, b) + GeObList(d, d) + GeObList(f, f));
  419.   APoint pt27(domsp, GeObList(b, b) + GeObList(d, d) + GeObList(f, f));
  420.  
  421.   APoint xout;
  422.   xout = tstmp(pt1);
  423.   truth((xout - aa_cc_ee).IsZeroVector(), TRUE);
  424.   xout = tstmp(pt2);
  425.   truth((xout - ab_cc_ee).IsZeroVector(), TRUE);
  426.   xout = tstmp(pt3);
  427.   truth((xout - bb_cc_ee).IsZeroVector(), TRUE);
  428.   xout = tstmp(pt4);
  429.   truth((xout - aa_cd_ee).IsZeroVector(), TRUE);
  430.   xout = tstmp(pt5);
  431.   truth((xout - ab_cd_ee).IsZeroVector(), TRUE);
  432.   xout = tstmp(pt6);
  433.   truth((xout - bb_cd_ee).IsZeroVector(), TRUE);
  434.   xout = tstmp(pt7);
  435.   truth((xout - aa_dd_ee).IsZeroVector(), TRUE);
  436.   xout = tstmp(pt8);
  437.   truth((xout - ab_dd_ee).IsZeroVector(), TRUE);
  438.   xout = tstmp(pt9);
  439.   truth((xout - bb_dd_ee).IsZeroVector(), TRUE);
  440.   xout = tstmp(pt10);
  441.   truth((xout - aa_cc_ef).IsZeroVector(), TRUE);
  442.   xout = tstmp(pt11);
  443.   truth((xout - ab_cc_ef).IsZeroVector(), TRUE);
  444.   xout = tstmp(pt12);
  445.   truth((xout - bb_cc_ef).IsZeroVector(), TRUE);
  446.   xout = tstmp(pt13);
  447.   truth((xout - aa_cd_ef).IsZeroVector(), TRUE);
  448.   xout = tstmp(pt14);
  449.   truth((xout - ab_cd_ef).IsZeroVector(), TRUE);
  450.   xout = tstmp(pt15);
  451.   truth((xout - bb_cd_ef).IsZeroVector(), TRUE);
  452.   xout = tstmp(pt16);
  453.   truth((xout - aa_dd_ef).IsZeroVector(), TRUE);
  454.   xout = tstmp(pt17);
  455.   truth((xout - ab_dd_ef).IsZeroVector(), TRUE);
  456.   xout = tstmp(pt18);
  457.   truth((xout - bb_dd_ef).IsZeroVector(), TRUE);
  458.   xout = tstmp(pt19);
  459.   truth((xout - aa_cc_ff).IsZeroVector(), TRUE);
  460.   xout = tstmp(pt20);
  461.   truth((xout - ab_cc_ff).IsZeroVector(), TRUE);
  462.   xout = tstmp(pt21);
  463.   truth((xout - bb_cc_ff).IsZeroVector(), TRUE);
  464.   xout = tstmp(pt22);
  465.   truth((xout - aa_cd_ff).IsZeroVector(), TRUE);
  466.   xout = tstmp(pt23);
  467.   truth((xout - ab_cd_ff).IsZeroVector(), TRUE);
  468.   xout = tstmp(pt24);
  469.   truth((xout - bb_cd_ff).IsZeroVector(), TRUE);
  470.   xout = tstmp(pt25);
  471.   truth((xout - aa_dd_ff).IsZeroVector(), TRUE);
  472.   xout = tstmp(pt26);
  473.   truth((xout - ab_dd_ff).IsZeroVector(), TRUE);
  474.   xout = tstmp(pt27);
  475.   truth((xout - bb_dd_ff).IsZeroVector(), TRUE);
  476. }
  477.  
  478. // ***********************************************************************
  479. //  Test from 1 x 2 -> 3
  480.  
  481. void test4(void)
  482. {
  483.   cout << "ENTERING TEST4\n";
  484.   beauty();
  485.   ASpace paramef("paramef", 1, TRUE);
  486.   Simplex smp1 = paramef.StdSimplex();
  487.  
  488.   ASpace param2("param2", 2, TRUE);
  489.   Simplex smp2 = param2.StdSimplex();
  490.  
  491.   APoint sef1(smp1, ScalarList(0.3, 0.7));
  492.   APoint sef2(smp1, ScalarList(1.3, -0.3));
  493.  
  494.   Simplex mysmpef("my simplexab", paramef, GeObList(sef1, sef2));
  495.  
  496.   APoint s1(smp2, ScalarList(0.4, 0.3, 0.3));
  497.   APoint s2(smp2, ScalarList(1.5, 2.0, -2.5));
  498.   APoint s3(smp2, ScalarList(0.9, -0.3, 0.4));
  499.  
  500.   Simplex mysimp("my simplex2", param2, GeObList(s1, s2, s3));
  501.  
  502.   ASpace rng("rngspace", 3, TRUE);
  503.   Frame fr2 = rng.StdBasis();
  504.  
  505.   ASpace domsp("domsp", SpaceList(param2, param2, paramef, paramef), FALSE);
  506.  
  507.   IntList hold(2);
  508.   hold[0] = 2;
  509.   hold[1] = 2;
  510.  
  511.   APoint aa_ee(fr2, ScalarList(0.0, 0.0, 0.0, 1.0));
  512.   APoint ab_ee(fr2, ScalarList(1.0, 0.0, 0.3, 1.0));
  513.   APoint bb_ee(fr2, ScalarList(2.0, 0.0, 0.0, 1.0));
  514.   APoint ac_ee(fr2, ScalarList(0.5, 1.0, 0.3, 1.0));
  515.   APoint bc_ee(fr2, ScalarList(1.5, 1.0, 0.3, 1.0));
  516.   APoint cc_ee(fr2, ScalarList(1.0, 2.0, 0.0, 1.0));
  517.  
  518.   APoint aa_ef(fr2, ScalarList(0.0, 0.0, 1.0, 1.0));
  519.   APoint ab_ef(fr2, ScalarList(1.0, 0.0, 1.3, 1.0));
  520.   APoint bb_ef(fr2, ScalarList(2.0, 0.0, 1.0, 1.0));
  521.   APoint ac_ef(fr2, ScalarList(0.5, 1.0, 1.3, 1.0));
  522.   APoint bc_ef(fr2, ScalarList(1.5, 1.0, 1.3, 1.0));
  523.   APoint cc_ef(fr2, ScalarList(1.0, 2.0, 1.0, 1.0));
  524.  
  525.   APoint aa_ff(fr2, ScalarList(0.0, 0.0, 2.0, 1.0));
  526.   APoint ab_ff(fr2, ScalarList(1.0, 0.0, 2.3, 1.0));
  527.   APoint bb_ff(fr2, ScalarList(2.0, 0.0, 2.0, 1.0));
  528.   APoint ac_ff(fr2, ScalarList(0.5, 1.0, 2.3, 1.0));
  529.   APoint bc_ff(fr2, ScalarList(1.5, 1.0, 2.3, 1.0));
  530.   APoint cc_ff(fr2, ScalarList(1.0, 2.0, 2.0, 1.0));
  531.   
  532.   GeObList net = GeObList(aa_ee, aa_ef, aa_ff) +
  533.          GeObList(ab_ee, ab_ef, ab_ff) +
  534.          GeObList(bb_ee, bb_ef, bb_ff) +
  535.          GeObList(ac_ee, ac_ef, ac_ff) +
  536.          GeObList(bc_ee, bc_ef, bc_ff) +
  537.          GeObList(cc_ee, cc_ef, cc_ff);
  538.  
  539.   MAM tstmp;
  540.   tstmp = MAM(domsp, hold, BasisList(mysimp, mysmpef), rng, net);
  541.  
  542.   APoint a(mysimp, ScalarList(1.0, 0.0, 0.0));
  543.   APoint b(mysimp, ScalarList(0.0, 1.0, 0.0));
  544.   APoint c(mysimp, ScalarList(0.0, 0.0, 1.0));
  545.  
  546.   APoint e(mysmpef, ScalarList(1.0, 0.0));
  547.   APoint f(mysmpef, ScalarList(0.0, 1.0));
  548.  
  549.   APoint pt1(domsp, GeObList(a, a, e, e));
  550.   APoint pt2(domsp, GeObList(a, b, e, e));
  551.   APoint pt3(domsp, GeObList(b, b, e, e));
  552.   APoint pt4(domsp, GeObList(a, c, e, e));
  553.   APoint pt5(domsp, GeObList(b, c, e, e));
  554.   APoint pt6(domsp, GeObList(c, c, e, e));
  555.   APoint pt7(domsp, GeObList(a, a, e, f));
  556.   APoint pt8(domsp, GeObList(a, b, e, f));
  557.   APoint pt9(domsp, GeObList(b, b, e, f));
  558.   APoint pt10(domsp, GeObList(a, c, e, f));
  559.   APoint pt11(domsp, GeObList(b, c, e, f));
  560.   APoint pt12(domsp, GeObList(c, c, e, f));
  561.   APoint pt13(domsp, GeObList(a, a, f, f));
  562.   APoint pt14(domsp, GeObList(a, b, f, f));
  563.   APoint pt15(domsp, GeObList(b, b, f, f));
  564.   APoint pt16(domsp, GeObList(a, c, f, f));
  565.   APoint pt17(domsp, GeObList(b, c, f, f));
  566.   APoint pt18(domsp, GeObList(c, c, f, f));
  567.  
  568.   APoint xout;
  569.   xout = tstmp(pt1);
  570.   truth((xout - aa_ee).IsZeroVector(), TRUE);
  571.   xout = tstmp(pt2);
  572.   truth((xout - ab_ee).IsZeroVector(), TRUE);
  573.   xout = tstmp(pt3);
  574.   truth((xout - bb_ee).IsZeroVector(), TRUE);
  575.   xout = tstmp(pt4);
  576.   truth((xout - ac_ee).IsZeroVector(), TRUE);
  577.   xout = tstmp(pt5);
  578.   truth((xout - bc_ee).IsZeroVector(), TRUE);
  579.   xout = tstmp(pt6);
  580.   truth((xout - cc_ee).IsZeroVector(), TRUE);
  581.   xout = tstmp(pt7);
  582.   truth((xout - aa_ef).IsZeroVector(), TRUE);
  583.   xout = tstmp(pt8);
  584.   truth((xout - ab_ef).IsZeroVector(), TRUE);
  585.   xout = tstmp(pt9);
  586.   truth((xout - bb_ef).IsZeroVector(), TRUE);
  587.   xout = tstmp(pt10);
  588.   truth((xout - ac_ef).IsZeroVector(), TRUE);
  589.   xout = tstmp(pt11);
  590.   truth((xout - bc_ef).IsZeroVector(), TRUE);
  591.   xout = tstmp(pt12);
  592.   truth((xout - cc_ef).IsZeroVector(), TRUE);
  593.   xout = tstmp(pt13);
  594.   truth((xout - aa_ff).IsZeroVector(), TRUE);
  595.   xout = tstmp(pt14);
  596.   truth((xout - ab_ff).IsZeroVector(), TRUE);
  597.   xout = tstmp(pt15);
  598.   truth((xout - bb_ff).IsZeroVector(), TRUE);
  599.   xout = tstmp(pt16);
  600.   truth((xout - ac_ff).IsZeroVector(), TRUE);
  601.   xout = tstmp(pt17);
  602.   truth((xout - bc_ff).IsZeroVector(), TRUE);
  603.   xout = tstmp(pt18);
  604.   truth((xout - cc_ff).IsZeroVector(), TRUE);
  605. }
  606.  
  607. // ***********************************************************************
  608. // Test from 3 -> 3
  609.  
  610. void test5(void)
  611. {
  612.   cout << "ENTERING TEST5\n";
  613.   beauty();
  614.   ASpace param("paramspace", 3, TRUE);
  615.   Simplex smp1 = param.StdSimplex();
  616.  
  617.   APoint s1(smp1, ScalarList(0.2, 0.3, 0.3, 0.2));
  618.   APoint s2(smp1, ScalarList(1.0, 2.0, -2.5, 0.5));
  619.   APoint s3(smp1, ScalarList(0.6, -0.3, 0.4, 0.3));
  620.   APoint s4(smp1, ScalarList(1.7, -0.9, 0.1, 0.1));
  621.  
  622.   Simplex mysimp("my simplex", param, GeObList(s1, s2, s3, s4));
  623.  
  624.   ASpace rng("rngspace", 3, TRUE);
  625.   Frame fr2 = rng.StdBasis();
  626.  
  627.   ASpace domsp("testdom", SpaceList(param, 2), FALSE);
  628.  
  629.   IntList hold(1);
  630.   hold[0] = 2;
  631.  
  632.   APoint aa(fr2, ScalarList(0.0, 0.0, 0.0, 1.0));
  633.   APoint ab(fr2, ScalarList(1.0, 0.0, 0.0, 1.0));
  634.   APoint bb(fr2, ScalarList(2.0, 0.0, 0.0, 1.0));
  635.   APoint ac(fr2, ScalarList(0.5, 1.0, 0.0, 1.0));
  636.   APoint bc(fr2, ScalarList(1.5, 1.0, 0.0, 1.0));
  637.   APoint cc(fr2, ScalarList(1.0, 2.0, 0.0, 1.0));
  638.   APoint da(fr2, ScalarList(0.5, 0.5, 1.0, 1.0));
  639.   APoint db(fr2, ScalarList(1.5, 0.5, 1.0, 1.0));
  640.   APoint dc(fr2, ScalarList(2.5, 0.5, 1.0, 1.0));
  641.   APoint dd(fr2, ScalarList(1.0, 1.0, 2.0, 1.0));
  642.   
  643.   GeObList net = GeObList(aa, ab, bb) +
  644.          GeObList(ac, bc, cc) +
  645.          GeObList(da, db, dc, dd);
  646.  
  647.   MAM tstmp(domsp, hold, BasisList(mysimp), rng, net);
  648.  
  649.   APoint pt1(mysimp, ScalarList(1.0, 0.0, 0.0, 0.0));
  650.   APoint pt2(mysimp, ScalarList(0.0, 1.0, 0.0, 0.0));
  651.   APoint pt3(mysimp, ScalarList(0.0, 0.0, 1.0, 0.0));
  652.   APoint pt4(mysimp, ScalarList(0.0, 0.0, 0.0, 1.0));
  653.  
  654.   APoint apt1(domsp, pt1, pt1);
  655.   APoint apt2(domsp, pt1, pt2);
  656.   APoint apt3(domsp, pt2, pt2);
  657.   APoint apt4(domsp, pt1, pt3);
  658.   APoint apt5(domsp, pt2, pt3);
  659.   APoint apt6(domsp, pt3, pt3);
  660.   APoint apt7(domsp, pt4, pt1);
  661.   APoint apt8(domsp, pt4, pt2);
  662.   APoint apt9(domsp, pt4, pt3);
  663.   APoint apt10(domsp, pt4, pt4);
  664.  
  665.   APoint xout;
  666.   xout = tstmp(apt1);
  667.   truth((xout - aa).IsZeroVector(), TRUE);
  668.   xout = tstmp(apt2);
  669.   truth((xout - ab).IsZeroVector(), TRUE);
  670.   xout = tstmp(apt3);
  671.   truth((xout - bb).IsZeroVector(), TRUE);
  672.   xout = tstmp(apt4);
  673.   truth((xout - ac).IsZeroVector(), TRUE);
  674.   xout = tstmp(apt5);
  675.   truth((xout - bc).IsZeroVector(), TRUE);
  676.   xout = tstmp(apt6);
  677.   truth((xout - cc).IsZeroVector(), TRUE);
  678.   xout = tstmp(apt7);
  679.   truth((xout - da).IsZeroVector(), TRUE);
  680.   xout = tstmp(apt8);
  681.   truth((xout - db).IsZeroVector(), TRUE);
  682.   xout = tstmp(apt9);
  683.   truth((xout - dc).IsZeroVector(), TRUE);
  684.   xout = tstmp(apt10);
  685.   truth((xout - dd).IsZeroVector(), TRUE);
  686. }
  687.  
  688. // ***********************************************************************
  689. //  General linear map
  690.  
  691. void test6(void)
  692. {
  693.   cout << "ENTERING TEST6\n";
  694.   beauty();
  695.   VSpace param("param", 2, TRUE);
  696.   VBasis vba1 = param.StdBasis();
  697.  
  698.   VSpace rng("rngspace", 3, TRUE);
  699.   VBasis vba2 = rng.StdBasis();
  700.  
  701.   VSpace domsp("domsp", SpaceList(param, param, param), FALSE);
  702.  
  703.   Vector b1(vba1, ScalarList(0.3, 1.4));
  704.   Vector b2(vba1, ScalarList(2.1, 3.2));
  705.  
  706.   VBasis myvba("my basis", param, GeObList(b1, b2));
  707.  
  708.   IntList hold(1, 1, 1);
  709.  
  710.   Vector aaa(vba2, ScalarList(0.0, 0.0, 0.0));
  711.   Vector aab(vba2, ScalarList(0.0, 2.0, 0.0));
  712.   Vector aba(vba2, ScalarList(2.0, 0.0, 0.0));
  713.   Vector abb(vba2, ScalarList(2.0, 2.0, 0.0));
  714.   Vector baa(vba2, ScalarList(0.0, 0.0, 1.0));
  715.   Vector bab(vba2, ScalarList(0.0, 1.0, 1.0));
  716.   Vector bba(vba2, ScalarList(1.0, 0.0, 1.0));
  717.   Vector bbb(vba2, ScalarList(1.0, 1.0, 1.0));
  718.   
  719.   GeObList net = GeObList(aaa, aab, aba, abb) + GeObList(baa, bab, bba, bbb);
  720.  
  721.   MLM tstmp;
  722.   tstmp = MLM(domsp, hold, BasisList(myvba, myvba, myvba), rng, net);
  723.  
  724.   Vector a(myvba, ScalarList(1.0, 0.0));
  725.   Vector b(myvba, ScalarList(0.0, 1.0));
  726.  
  727.   Vector v1(domsp, GeObList(a, a, a));
  728.   Vector v2(domsp, GeObList(a, a, b));
  729.   Vector v3(domsp, GeObList(a, b, a));
  730.   Vector v4(domsp, GeObList(a, b, b));
  731.   Vector v5(domsp, GeObList(b, a, a));
  732.   Vector v6(domsp, GeObList(b, a, b));
  733.   Vector v7(domsp, GeObList(b, b, a));
  734.   Vector v8(domsp, GeObList(b, b, b));
  735.  
  736.   Vector xout;
  737.   xout = tstmp(v1);
  738.   truth((xout - aaa).IsZeroVector(), TRUE);
  739.   xout = tstmp(v2);
  740.   truth((xout - aab).IsZeroVector(), TRUE);
  741.   xout = tstmp(v3);
  742.   truth((xout - aba).IsZeroVector(), TRUE);
  743.   xout = tstmp(v4);
  744.   truth((xout - abb).IsZeroVector(), TRUE);
  745.   xout = tstmp(v5);
  746.   truth((xout - baa).IsZeroVector(), TRUE);
  747.   xout = tstmp(v6);
  748.   truth((xout - bab).IsZeroVector(), TRUE);
  749.   xout = tstmp(v7);
  750.   truth((xout - bba).IsZeroVector(), TRUE);
  751.   xout = tstmp(v8);
  752.   truth((xout - bbb).IsZeroVector(), TRUE);
  753. }
  754.  
  755. // ***********************************************************************
  756. // Antisymmetric MLM:
  757.  
  758. void test7(void)
  759. {
  760. // Define a MLM on a 4-d space that takes 3 arguments
  761.  
  762.   cout << "ENTERING TEST7\n";
  763.   beauty();
  764.  
  765.   VSpace param("param", 4, TRUE);
  766.   VBasis vba1 = param.StdBasis();
  767.  
  768.   VSpace rng("rngspace", 4, TRUE);
  769.   VBasis vba2 = rng.StdBasis();
  770.  
  771.   VSpace domsp("domsp", SpaceList(param, param, param), FALSE);
  772.  
  773.   Vector b1(vba1, ScalarList(0.3, 1.4, 2.3, 4.5));
  774.   Vector b2(vba1, ScalarList(2.1, 3.2, 1.1, 7.6));
  775.   Vector b3(vba1, ScalarList(6.7, -3.4, -2.5, 9.7));
  776.   Vector b4(vba1, ScalarList(-5.2, 8.5, 1.1, 3.4));
  777.  
  778.   VBasis myvba("my basis", param, GeObList(b1, b2, b3, b4));
  779.  
  780.   IntList hold(1);
  781.   hold[0] = -3;
  782.  
  783.   Vector abc(vba2, ScalarList(1.0, 0.0, 0.0, 0.0));
  784.   Vector abd(vba2, ScalarList(0.0, 2.0, 0.0, 2.0));
  785.   Vector acd(vba2, ScalarList(2.0, 0.0, 2.0, 0.0));
  786.   Vector bcd(vba2, ScalarList(2.0, 2.0, 0.0, 0.0));
  787.   
  788.   GeObList net = GeObList(abc, abd, acd, bcd);
  789.  
  790.   MLM tstmp;
  791.   tstmp = MLM(domsp, hold, BasisList(myvba), rng, net);
  792.  
  793.   Vector a(myvba, ScalarList(1.0, 0.0, 0.0, 0.0));
  794.   Vector b(myvba, ScalarList(0.0, 1.0, 0.0, 0.0));
  795.   Vector c(myvba, ScalarList(0.0, 0.0, 1.0, 0.0));
  796.   Vector d(myvba, ScalarList(0.0, 0.0, 0.0, 1.0));
  797.  
  798.   Vector v1(domsp, GeObList(a, b, c));
  799.   Vector v2(domsp, GeObList(a, b, d));
  800.   Vector v3(domsp, GeObList(a, c, d));
  801.   Vector v4(domsp, GeObList(b, c, d));
  802.  
  803.   Vector v5(domsp, GeObList(b, a, c));
  804.   Vector v6(domsp, GeObList(d, b, a));
  805.   Vector v7(domsp, GeObList(a, d, c));
  806.   Vector v8(domsp, GeObList(d, b, c));
  807.  
  808.   Vector xout;
  809.   xout = tstmp(v1);
  810.   truth((xout - abc).IsZeroVector(), TRUE);
  811.   xout = tstmp(v2);
  812.   truth((xout - abd).IsZeroVector(), TRUE);
  813.   xout = tstmp(v3);
  814.   truth((xout - acd).IsZeroVector(), TRUE);
  815.   xout = tstmp(v4);
  816.   truth((xout - bcd).IsZeroVector(), TRUE);
  817.   xout = tstmp(v5);
  818.   truth((xout + abc).IsZeroVector(), TRUE);
  819.   xout = tstmp(v6);
  820.   truth((xout + abd).IsZeroVector(), TRUE);
  821.   xout = tstmp(v7);
  822.   truth((xout + acd).IsZeroVector(), TRUE);
  823.   xout = tstmp(v8);
  824.   truth((xout - bcd).IsZeroVector(), TRUE);
  825. }
  826.  
  827. // ***********************************************************************
  828. // Antisymmetric MLM:
  829.  
  830. void test8(void)
  831. {
  832. // Define a MLM on a 4-d space that takes 2 arguments
  833.  
  834.   cout << "ENTERING TEST8\n";
  835.   beauty();
  836.  
  837.   VSpace param("param", 4, TRUE);
  838.   VBasis vba1 = param.StdBasis();
  839.  
  840.   VSpace rng("rngspace", 4, TRUE);
  841.   VBasis vba2 = rng.StdBasis();
  842.  
  843.   VSpace domsp("domsp", SpaceList(param, param), FALSE);
  844.  
  845.   Vector b1(vba1, ScalarList(0.3, 1.4, 2.3, 4.5));
  846.   Vector b2(vba1, ScalarList(2.1, 3.2, 1.1, 7.6));
  847.   Vector b3(vba1, ScalarList(6.7, -3.4, -2.5, 9.7));
  848.   Vector b4(vba1, ScalarList(-5.2, 8.5, 1.1, 3.4));
  849.  
  850.   VBasis myvba("my basis", param, GeObList(b1, b2, b3, b4));
  851.  
  852.   IntList hold(1);
  853.   hold[0] = -2;
  854.  
  855.   Vector ab(vba2, ScalarList(1.0, 0.0, 0.0, 0.0));
  856.   Vector ac(vba2, ScalarList(0.0, 2.0, 0.0, 5.0));
  857.   Vector bc(vba2, ScalarList(2.0, 0.0, 7.0, 0.0));
  858.   Vector ad(vba2, ScalarList(2.0, 3.0, 0.0, 0.0));
  859.   Vector bd(vba2, ScalarList(5.0, 0.0, 1.0, 0.0));
  860.   Vector cd(vba2, ScalarList(8.0, 2.0, 4.0, 3.0));
  861.   
  862.   GeObList net = GeObList(ab, ac, bc) + GeObList(ad, bd, cd);
  863.  
  864.   MLM tstmp;
  865.   tstmp = MLM(domsp, hold, BasisList(myvba), rng, net);
  866.  
  867.   Vector a(myvba, ScalarList(1.0, 0.0, 0.0, 0.0));
  868.   Vector b(myvba, ScalarList(0.0, 1.0, 0.0, 0.0));
  869.   Vector c(myvba, ScalarList(0.0, 0.0, 1.0, 0.0));
  870.   Vector d(myvba, ScalarList(0.0, 0.0, 0.0, 1.0));
  871.  
  872.   Vector v1(domsp, GeObList(a, b));
  873.   Vector v2(domsp, GeObList(a, c));
  874.   Vector v3(domsp, GeObList(b, c));
  875.   Vector v4(domsp, GeObList(a, d));
  876.   Vector v5(domsp, GeObList(b, d));
  877.   Vector v6(domsp, GeObList(c, d));
  878.  
  879.   Vector v7(domsp, GeObList(b, a));
  880.   Vector v8(domsp, GeObList(c, b));
  881.   Vector v9(domsp, GeObList(d, b));
  882.   Vector v10(domsp, GeObList(d, a));
  883.  
  884.   Vector xout;
  885.   xout = tstmp(v1);
  886.   truth((xout - ab).IsZeroVector(), TRUE);
  887.   xout = tstmp(v2);
  888.   truth((xout - ac).IsZeroVector(), TRUE);
  889.   xout = tstmp(v3);
  890.   truth((xout - bc).IsZeroVector(), TRUE);
  891.   xout = tstmp(v4);
  892.   truth((xout - ad).IsZeroVector(), TRUE);
  893.   xout = tstmp(v5);
  894.   truth((xout - bd).IsZeroVector(), TRUE);
  895.   xout = tstmp(v6);
  896.   truth((xout - cd).IsZeroVector(), TRUE);
  897.   xout = tstmp(v7);
  898.   truth((xout + ab).IsZeroVector(), TRUE);
  899.   xout = tstmp(v8);
  900.   truth((xout + bc).IsZeroVector(), TRUE);
  901.   xout = tstmp(v9);
  902.   truth((xout + bd).IsZeroVector(), TRUE);
  903.   xout = tstmp(v10);
  904.   truth((xout + ad).IsZeroVector(), TRUE);
  905. }
  906.  
  907. // ***********************************************************************
  908. // Create Multimap from a geob
  909. // a vector -> map from dual to real -> mlm
  910.  
  911. void test9(void)
  912. {
  913.   cout << "ENTERING TEST9\n";
  914.   beauty();
  915.   VSpace v1("v1space", 4, TRUE);
  916.   VBasis bas1 = v1.StdBasis();
  917.  
  918.   Vector foo(bas1, ScalarList(7.2, 3.4, 12.1, 6.7));
  919.   Vector bar(bas1, ScalarList(12.3, 4.1, 3.6, 3.2));
  920.   Vector bard = bar.Dual();
  921.  
  922.   MLM foomap(foo);
  923.   
  924.   Scalar res1 = foo.Apply(bard);
  925.   Scalar res = foomap(bard).ToScalar();
  926.   cout << "res1: " << res1 << "\n";
  927.   cout << "res: " << res << "\n";
  928.  
  929.   MLM part = foomap(GeObList(bard));
  930.   truth((part.RangeSpace() == Reals), TRUE);
  931.   truth(part.FullyEvaluated(), TRUE);
  932.   Scalar res2 = part.ToScalar();
  933.   cout << "res2: " << res2 << "\n";
  934. }
  935.  
  936. // ***********************************************************************
  937. // Create Multimap from a map
  938. //
  939. // affine -> vector
  940. // affine -> affine
  941. // vector -> vector
  942. //
  943.  
  944. void test10(void)
  945. {
  946.   cout << "ENTERING TEST10\n";
  947.   beauty();
  948.   VSpace vs1("vs1", 3, TRUE);
  949.   VSpace vs2("vs2", 3, TRUE);
  950.   ASpace as1("as1", 2, TRUE);
  951.   ASpace as2("as2", 2, TRUE);
  952.  
  953. // Create an affine map:
  954.  
  955.   Frame fra1 = as1.StdBasis();
  956.   Frame fra2 = as2.StdBasis();
  957.   APoint a1(fra1, ScalarList(3.6, -4.5, 1.0));
  958.   APoint a2(fra1, ScalarList(2.2, 5.1, 1.0));
  959.   APoint a3(fra1, ScalarList(-6.7, 2.3, 1.0));
  960.   APoint a4(fra1, ScalarList(-1.4, -7.9, 1.0));
  961.  
  962.   Simplex s1("test simplex", as1, GeObList(a1, a2, a3));
  963.   Simplex std = as2.StdSimplex();
  964.   AffineMap am1(s1, std);
  965.  
  966.   MAM mam1(am1);
  967.  
  968.   GeOb xout;
  969.   GeOb comp;
  970.   xout = am1(a1);
  971.   comp = mam1(a1);
  972.   truth(comp.Holds() == AFF_POINT, TRUE);
  973.   truth((xout - comp).IsZeroVector(), TRUE);
  974.   xout = am1(a2);
  975.   comp = mam1(a2);
  976.   truth((xout - comp).IsZeroVector(), TRUE);
  977.   xout = am1(a3);
  978.   comp = mam1(a3);
  979.   truth((xout - comp).IsZeroVector(), TRUE);
  980.   xout = am1(a4);
  981.   comp = mam1(a4);
  982.   truth((xout - comp).IsZeroVector(), TRUE);
  983.   xout = am1(a4 - a3);
  984.   comp = mam1(a4 - a3);
  985.   truth(comp.Holds() == AFF_VECTOR, TRUE);
  986.   truth((xout - comp).IsZeroVector(), TRUE);
  987.  
  988. // Create a linear map:
  989.  
  990.   VBasis bas1 = vs1.StdBasis();
  991.   VBasis bas2 = vs2.StdBasis();
  992.   Vector v1(bas1, ScalarList(3.6, 4.5, -2.3));
  993.   Vector v2(bas1, ScalarList(2.2, -1.5, -1.4));
  994.   Vector v3(bas1, ScalarList(-7.6, 2.3, 3.5));
  995.   Vector v4(bas1, ScalarList(-1.4, -7.9, 8.9));
  996.  
  997.   VBasis b1("test basis", vs1, GeObList(v1, v2, v3));
  998.   LinearMap lm1(b1, bas2);
  999.  
  1000.   MLM mlm1(lm1);
  1001.  
  1002.   xout = lm1(v1);
  1003.   comp = mlm1(v1);
  1004.   truth(comp.Holds() == VECTOR, TRUE);
  1005.   truth((xout - comp).IsZeroVector(), TRUE);
  1006.   xout = lm1(v2);
  1007.   comp = mlm1(v2);
  1008.   truth((xout - comp).IsZeroVector(), TRUE);
  1009.   xout = lm1(v3);
  1010.   comp = mlm1(v3);
  1011.   truth((xout - comp).IsZeroVector(), TRUE);
  1012.   xout = lm1(v4);
  1013.   comp = mlm1(v4);
  1014.   truth((xout - comp).IsZeroVector(), TRUE);
  1015.  
  1016. // Create affine maps to vector space:
  1017.  
  1018.   VSubSet vsub1("2dvec", vs1, GeObList(v1, v2));
  1019.   AffineMap am2(s1, vsub1, GeObList(v1, v2, v1 + v2));
  1020.  
  1021.   ASubSet asub1("2daff", vs1, GeObList(v1, v2, v3));
  1022.   AffineMap am3(s1, asub1, GeObList(v1, v2, v3));
  1023.   
  1024.   MAM mam2(am2); 
  1025.  
  1026.   xout = am2(a1);
  1027.   comp = mam2(a1);
  1028.   truth(comp.Holds() == VECTOR, TRUE);
  1029.   truth((xout - comp).IsZeroVector(), TRUE);
  1030.   xout = am2(a2);
  1031.   comp = mam2(a2);
  1032.   truth((xout - comp).IsZeroVector(), TRUE);
  1033.   xout = am2(a3);
  1034.   comp = mam2(a3);
  1035.   truth((xout - comp).IsZeroVector(), TRUE);
  1036.   xout = am2(a4);
  1037.   comp = mam2(a4);
  1038.   truth((xout - comp).IsZeroVector(), TRUE);
  1039.   xout = am2(a4 - a3);
  1040.   comp = mam2(a4 - a3);
  1041.   truth(comp.Holds() == VECTOR, TRUE);
  1042.   truth((xout - comp).IsZeroVector(), TRUE);
  1043.  
  1044.   MAM mam3(am3); 
  1045.  
  1046.   xout = am3(a1);
  1047.   comp = mam3(a1);
  1048.   truth(comp.Holds() == VECTOR, TRUE);
  1049.   truth((xout - comp).IsZeroVector(), TRUE);
  1050.   xout = am3(a2);
  1051.   comp = mam3(a2);
  1052.   truth((xout - comp).IsZeroVector(), TRUE);
  1053.   xout = am3(a3);
  1054.   comp = mam3(a3);
  1055.   truth((xout - comp).IsZeroVector(), TRUE);
  1056.   xout = am3(a4);
  1057.   comp = mam3(a4);
  1058.   truth((xout - comp).IsZeroVector(), TRUE);
  1059.   xout = am3(a4 - a3);
  1060.   comp = mam3(a4 - a3);
  1061.   truth(comp.Holds() == VECTOR, TRUE);
  1062.   truth((xout - comp).IsZeroVector(), TRUE);
  1063. }
  1064.  
  1065. // ***********************************************************************
  1066. // Test more range changes and partial evaluation
  1067.  
  1068. void test11(void)
  1069. {
  1070.   cout << "ENTERING TEST11\n";
  1071.   beauty();
  1072.   ASpace param("paramspace", 1, TRUE);
  1073.   Simplex smp1 = param.StdSimplex();
  1074.  
  1075.   APoint s1(smp1, ScalarList(0.2, 0.8));
  1076.   APoint s2(smp1, ScalarList(0.5, 0.5));
  1077.  
  1078.   Simplex mysimp("my simplex", param, GeObList(s1, s2));
  1079.  
  1080.   ASpace rng("rngspace", 2, TRUE);
  1081.   Frame fr2 = rng.StdBasis();
  1082.  
  1083.   ASpace domsp("testdom", SpaceList(param, 4), FALSE);
  1084.  
  1085.   IntList hold(1);
  1086.   hold[0] = 4;
  1087.  
  1088.   APoint aaaa(fr2, ScalarList(0.0, 0.0, 1.0));
  1089.   APoint aaab(fr2, ScalarList(1.0, 1.0, 1.0));
  1090.   APoint aabb(fr2, ScalarList(1.5, 1.5, 1.0));
  1091.   APoint abbb(fr2, ScalarList(2.0, 0.7, 1.0));
  1092.   APoint bbbb(fr2, ScalarList(2.5, 1.0, 1.0));
  1093.   
  1094.   GeObList net = GeObList(aaaa, aaab, aabb) + GeObList(abbb, bbbb);
  1095.  
  1096.   MAM tstmp(domsp, hold, BasisList(mysimp), rng, net);
  1097.  
  1098.   APoint pt1(mysimp, ScalarList(1.0, 0.0));
  1099.   APoint pt2(mysimp, ScalarList(0.0, 1.0));
  1100.  
  1101.   APoint apt1(domsp, GeObList(pt1, pt1, pt1, pt1));
  1102.   APoint apt2(domsp, GeObList(pt1, pt1, pt1, pt2));
  1103.   APoint apt3(domsp, GeObList(pt1, pt1, pt2, pt2));
  1104.   APoint apt4(domsp, GeObList(pt1, pt2, pt2, pt2));
  1105.   APoint apt5(domsp, GeObList(pt2, pt2, pt2, pt2));
  1106.  
  1107.   APoint xout;
  1108.   xout = tstmp(apt1);
  1109.   truth((xout - aaaa).IsZeroVector(), TRUE);
  1110.   xout = tstmp(apt2);
  1111.   truth((xout - aaab).IsZeroVector(), TRUE);
  1112.   xout = tstmp(apt3);
  1113.   truth((xout - aabb).IsZeroVector(), TRUE);
  1114.   xout = tstmp(apt4);
  1115.   truth((xout - abbb).IsZeroVector(), TRUE);
  1116.   xout = tstmp(apt5);
  1117.   truth((xout - bbbb).IsZeroVector(), TRUE);
  1118.  
  1119. // Test partial evaluation
  1120.  
  1121.   GeObList part = GeObList(pt1, NullGeOb, NullGeOb, pt2 - pt1);
  1122.   ASpace inter("inter", SpaceList(param, 2), FALSE);
  1123.   VSpace newrng = rng.GetSpace(TANGENT);  
  1124.  
  1125.   MAM mout = tstmp(inter, part);
  1126.   truth(mout.FullyEvaluated(), FALSE);
  1127.   truth(mout.DomainSpace() == inter, TRUE);
  1128.   truth(mout.RangeSpace() == newrng, TRUE);
  1129.  
  1130.   part = GeObList(pt1, pt1);
  1131.   AVector tout = mout(part);
  1132.   truth((tout - (aaab - aaaa)).IsZeroVector(), TRUE);
  1133.  
  1134. // Map to a linear space:
  1135.  
  1136.   VSpace vrng("vrng", 3, TRUE);
  1137.   VBasis vb1 = vrng.StdBasis();
  1138.   Vector vaaaa(vb1, ScalarList(0.0, 0.0, 3.4));
  1139.   Vector vaaab(vb1, ScalarList(1.0, 1.0, 6.5));
  1140.   Vector vaabb(vb1, ScalarList(1.5, 1.5, 1.2));
  1141.   Vector vabbb(vb1, ScalarList(2.0, 0.7, 3.5));
  1142.   Vector vbbbb(vb1, ScalarList(2.5, 1.0, 1.9));
  1143.   
  1144.   GeObList vnet = GeObList(vaaaa, vaaab, vaabb) + GeObList(vabbb, vbbbb);
  1145.  
  1146.   MAM vtstmp(domsp, hold, BasisList(mysimp), vrng, vnet);
  1147.  
  1148. // Test partial evaluation
  1149.  
  1150.   part = GeObList(pt1, NullGeOb, NullGeOb, pt2 - pt1);
  1151.  
  1152.   mout = vtstmp(inter, part);
  1153.   truth(mout.FullyEvaluated(), FALSE);
  1154.   truth(mout.DomainSpace() == inter, TRUE);
  1155.   truth(mout.RangeSpace() == vrng, TRUE);
  1156.  
  1157.   part = GeObList(pt1, pt1);
  1158.   GeOb gout = mout(part);
  1159.   truth((gout - (vaaab - vaaaa)).IsZeroVector(), TRUE);
  1160.   truth(gout.Holds() == VECTOR, TRUE);
  1161. }
  1162.